package com.wvmi.gmall.order.config;

import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * 描述:   <br>
 *
 * @author Wuminming <br>
 * 创建时间: 2023-11-29 18:34 <br>
 * <p>
 * Copyright: 2013 - 2023 www.szwcyq.com Inc. All rights reserved. <br>
 * 注意：本内容仅限于深圳市微创云启科技有限公司内部传阅，禁止外泄以及用于其他的商业目的<br>
 */
@Configuration
@EnableConfigurationProperties(ThreadPoolConfigProperties.class)
public class ThreadPoolConfig {

    @Bean
    public ThreadPoolExecutor executor(ThreadPoolConfigProperties properties){
        return new ThreadPoolExecutor(properties.getCoreSize(),properties.getMaxSize(), properties.getKeepAliveTime(), TimeUnit.SECONDS,new LinkedBlockingQueue<>(10000),(r) -> new Thread(r,"gmall线程池"),new ThreadPoolExecutor.AbortPolicy());
    }
}
